#include <bits/stdc++.h>
using namespace std;
const int maxd = 6+2;
int A[9];
int d[9][3];


int dp(int pos, int st, bool flg){
    if(pos == 0) return st==2;
    if(flg && d[pos][st]!=-1) return d[pos][st];
    int m = flg?9:A[pos];
    int ans = 0;
    for (int i = 0; i <= m; ++i) {
        if(st==2 || (st==1 && i==8) || i==4)
            ans += dp(pos-1, 2, flg||i<m);
        else if (i==3)
            ans += dp(pos-1, 1, flg||i<m);
        else ans += dp(pos-1, 0, flg||i<m);
    }
    if(flg) d[pos][st] = ans;
    return ans;
}

int cal(int x){
    int pos = 0;
    while (x){
        A[++pos] = x%10;
        x/=10;
    }
    return dp(pos, 0, false);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int a, b;

    memset(d, -1, sizeof(d));
    while (cin >> a >> b && (a || b)){
        cout << cal(b) - cal(a-1) << endl;
    }
    return 0;
}